package com.jwsoft.manager.core.gateway.controller;

import com.bifang.assistant.common.constants.Validators;
import com.bifang.engine.assistant.core.domain.AppResponse;
import com.bifang.engine.protect.core.annotation.Idempotent;
import com.github.pagehelper.PageInfo;
import com.jwsoft.manager.common.vo.eduAuthSchool.EduAuthSchoolKeyVO;
import com.jwsoft.manager.common.vo.eduAuthSchool.EduAuthSchoolQueryVO;
import com.jwsoft.manager.common.vo.eduAuthSchool.EduAuthSchoolVO;
import com.jwsoft.manager.core.integration.EduAuthSchoolIntegration;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 城区审核学校名单网关
 *
 * @author hhj
 * @since 2022-12-28
 */
@RestController
@RequestMapping(value = "/doc/api")
@Tag(name = "城区审核学校名单", description = "城区审核学校名单")
public class EduAuthSchoolController {

    @Autowired
    public EduAuthSchoolIntegration eduAuthSchoolIntegration;

    @Operation(summary = "城区审核学校名单分页查询",description = "城区审核学校名单分页查询")
    @PostMapping(value = "/eduAuthSchool0001", produces = "application/json;charset=UTF-8")
    public AppResponse<PageInfo<EduAuthSchoolVO>> getList(@RequestBody @Validated EduAuthSchoolQueryVO vo) {
        return AppResponse.successData(eduAuthSchoolIntegration.getList(vo));
    }

    @Operation(summary = "城区审核学校名单根据主键查询详情",description = "城区审核学校名单根据主键查询详情")
    @PostMapping(value = "/eduAuthSchool0002", produces = "application/json;charset=UTF-8")
    public AppResponse<EduAuthSchoolVO> getById(@RequestBody @Validated EduAuthSchoolKeyVO vo) {
        return AppResponse.successData(eduAuthSchoolIntegration.getById(vo));
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "城区审核学校名单新增",description = "城区审核学校名单新增")
    @PostMapping(value = "/eduAuthSchool0004", produces = "application/json;charset=UTF-8")
    public AppResponse<EduAuthSchoolVO> add(@RequestBody @Validated(value = {Validators.Add.class}) EduAuthSchoolVO vo) {
        return AppResponse.successData(eduAuthSchoolIntegration.add(vo));
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "城区审核学校名单修改",description = "城区审核学校名单修改")
    @PostMapping(value = "/eduAuthSchool0005", produces = "application/json;charset=UTF-8")
    public AppResponse<EduAuthSchoolVO> edit(@RequestBody @Validated(value = {Validators.Edit.class}) EduAuthSchoolVO vo) {
        return AppResponse.successData(eduAuthSchoolIntegration.edit(vo));
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "城区审核学校名单删除",description = "城区审核学校名单删除")
    @PostMapping(value = "/eduAuthSchool0006", produces = "application/json;charset=UTF-8")
    public AppResponse del(@RequestBody @Validated EduAuthSchoolKeyVO vo) {
        eduAuthSchoolIntegration.del(vo);
        return AppResponse.successMsg("删除成功！");
    }
}
